package edu.aysf.service;

import edu.aysf.config.FeignConfig;
import edu.aysf.service.fallback.ClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

// 三、创建一个服务消费者（Consumer）
// 调用服务 此处路径中的写法，要与被调用的服务路径一样
//@Service
//1 ok
//@FeignClient(name = "order-service", path = "/order")
//2 ok
//@FeignClient(name = "order-service", path = "/")
//3 ok
//@Component
// 避免启动时的阻塞问题
@Lazy
//@FeignClient(name = "order-service", url = "http://localhost:8081",fallbackFactory = ClientFallback.class,configuration = FeignConfig.class)
@FeignClient(name = "order-service", url = "http://localhost:8081",fallbackFactory = ClientFallback.class)

public interface ClientOrderService {
    @RequestMapping("/order/echo")
    // 本方法是一个没有实现的接口，具体实现在feiclient所调用的微服务种
    String echo(@RequestParam String string);

    @RequestMapping("/order/echo2/{string}")
    String echo2(@PathVariable("string") String string);

    @RequestMapping("/order/calc")
    String mycalc(@RequestParam("p1") int par1, @RequestParam("p2") int par2);

}
